import request from '@/utils/request'
let lawServicePlatform = "lawServicePlatform";

// 【采买方】

// 采买方获取法律求助表
// export function getLegalRecourseListToBuyer(data, pageNum, pageSize) {
//     return request({
//         url: "/lawServicePlatform/legalRecourse/getLegalRecourseListToBuyer?pageNum=" + pageNum + "&pageSize=" + pageSize,
//         method: 'post',
//         data
//     })
// }
export function getLegalRecourseListToBuyer(data, pageNum ,pageSize) {
    return request({
        url: "/lawServicePlatform/legalRecourse/getLegalRecourseListToBuyer?pageNum="+pageNum+"&pageSize="+pageSize,
        method: 'post',
        data
    })
}

// 新增法律求助信息
// 注意：！
// （1）该后端接口的时间必须是“2021-9-23 00:00:12”这样的格式！！！
// （2）serviceProviderId值为 null  !!!!
export function addLegalRecourse(data) {
    console.log("@/api/lawHelp.js: addLegalRecourse(data)执行");
    // 这一句打印在获取即时时间函数后、获取当前用户id前。
    return request({
        url: "/lawServicePlatform/legalRecourse/addLegalRecourse",
        method: 'post',
        data
    })
}

// 发布法律求助
export function putOnLegalRecourse(id) {
    return request({
        url: "/lawServicePlatform/legalRecourse/putOnLegalRecourse?id=" + id,
        method: 'post',
        // data
    })
}

// 修改法律求助信息
export function modifyLegalRecourse(data) {
    return request({
        url: "/lawServicePlatform/legalRecourse/modifyLegalRecourse",
        method: 'post',
        data
    })
}

// 删除法律求助
export function deleteLegalRecourse(id) {
    return request({
        url: "/lawServicePlatform/legalRecourse/deleteLegalRecourse?id=" + id,
        method: 'post',
    })
}

// 取消发布法律求助
export function takeDownLegalRecourse(id) {
    return request({
        url: "/lawServicePlatform/legalRecourse/takeDownLegalRecourse?id=" + id,
        method: 'post',
    })
}

// 选择服务商
export function selectServiceProvider(id) {
    return request({
        url: "/lawServicePlatform/legalRecourse/selectServiceProvider?id=" + id,
        method: 'post',
    })
}

// 通过法律求助id（和分页json）获取抢单表
export function getOrderGrabbingList(data, id) {
    return request({
        url: "/lawServicePlatform/legalRecourse/getOrderGrabbingList?id=" + id,
        method: 'post',
        data
    })
}


// 【服务商】

// 服务商获取法律求助表
export function getLegalRecourseListToServiceProvider(data, state, title) {
    console.log("/api/lawHelp.js: getLegalRecourseListToServiceProvider(dataPage, state, title)");
    console.log("state: "+state);
    console.log("title: "+title);
    // 对付接口的title空值路径格式改变的问题
    let urlTitle = "";
    if(title==""){
        urlTitle = "";
        // urlTitle = "&title="+title;
    }else{
        urlTitle = "&title="+title;
    }
    console.log("urlTitle: "+urlTitle);
    console.log("url: /lawServicePlatform/legalRecourse/getLegalRecourseListToServiceProvider?state="+state+urlTitle);
    // 
    return request({
        url: "/lawServicePlatform/legalRecourse/getLegalRecourseListToServiceProvider?state="+state+urlTitle,
        method: 'post',
        data
    })
    // 【踩坑】这里一定要用“data”，不能用“dataPage”之类的命名参数！！！！！！！！
}

// 新增抢单自荐信息
export function addOrderGrabbing(data) {
    return request({
        url: "/lawServicePlatform/legalRecourse/addOrderGrabbing",
        method: 'post',
        data
    })
}

// 服务商撤销抢单(传参：抢单id)
export function deleteOrderGrabbing(id) {
    return request({
        url: "/lawServicePlatform/deleteOrderGrabbing?id="+id,
        method: 'post',
    })
}

// 【共用】

// 通过法律求助id获取法律求助
export function getLegalRecourseById(id) {
    return request({
        url: "/lawServicePlatform/legalRecourse/getLegalRecourseById?id=" + id,
        method: 'post',
        // data
    })
}

